import Vue from 'vue'
import Vuex, { StoreOptions } from 'vuex'

Vue.use(Vuex)

// root interface
import { RootState } from '@/store/modules/types'

// root
import { state, getters, mutations, actions } from '@/store/modules'

import { companyTemplate } from '@/store/modules/common/company-template'

// cms 模块
import {
  state as adminState,
  getters as adminGetters,
  mutations as adminMutations,
  actions as adminActions
} from '@/store/modules/cms'
import { adminUser } from '@/store/modules/cms/admin/admin-user'
import { permission } from '@/store/modules/cms/admin/permission'
import { role } from '@/store/modules/cms/admin/role'
  // 个人
  import { personalUser } from '@/store/modules/cms/personal/personal-user'
  import { resume } from '@/store/modules/cms/personal/resume'
  import { resumeSend } from '@/store/modules/cms/personal/resume-send'
  import { personalUserRecord } from '@/store/modules/cms/personal/personal-user-record'
  // 企业
  import { companyUser } from '@/store/modules/cms/company/company-user'
  import { companyBasic } from '@/store/modules/cms/company/company-basic'
  import { companyJob } from '@/store/modules/cms/company/company-job'
  import { interview } from '@/store/modules/cms/company/interview'

// crm 模块
import {
  state as crmState,
  getters as crmGetters,
  mutations as crmMutations,
  actions as crmActions
} from '@/store/modules/crm'

const store: StoreOptions<RootState> = {
  strict: process.env.NODE_ENV !== 'production',
  state,
  getters,
  mutations,
  actions,
  modules: {
    common: {
      namespaced: true,
      modules: {
        companyTemplate
      }
    },
    cms: {
      namespaced: true,
      state: adminState,
      getters: adminGetters,
      mutations: adminMutations,
      actions: adminActions,
      modules: {
        adminUser,
        permission,
        role,

        personalUser,
        resume,
        resumeSend,
        personalUserRecord,

        companyUser,
        companyBasic,
        companyJob,
        interview
      }
    },
    crm: {
      namespaced: true,
      state: crmState,
      getters: crmGetters,
      mutations: crmMutations,
      actions: crmActions,
      modules: {
        // adminUser,
        // permission,
        // role
      }
    }
  }
}

export default new Vuex.Store<RootState>(store)
